/* soft_timer.c/h  3.0 */

#ifndef _SOFT_TIMER_H
#define _SOFT_TIMER_H

#include "main.h"

#define TIME_BASE_MS 100 //
#define TIMER_NUM 10
typedef enum {
    TURN_OK = 0x01, TURN_NO = 0x00,
} turn;
typedef void callback(void *argv, uint16_t argc);
typedef struct softTimer {
    uint8_t state;
    uint8_t mode;
    uint32_t match;
    uint32_t start;
    uint32_t period;
    turn turn;
    callback *cb;
    void *argv;
    uint16_t argc;
} softTimer;

typedef enum tmrState {
    SOFT_TIMER_STOPPED = 0, SOFT_TIMER_RUNNING, SOFT_TIMER_TIMEOUT
} tmrState;

typedef enum tmrMode {
    MODE_ONE_SHOT = 0, MODE_PERIODIC,
} tmrMode;

void tickCnt_Update(void);
uint32_t tickCnt_Get(void);
void softTimer_Init(void);
uint8_t softTimer_GetState(uint16_t id);
void softTimer_Start(uint16_t id, tmrMode mode, uint32_t delay, callback *cb,
                     void *argv, uint16_t argc);
void softTimer_Stop(uint16_t id);
void softTimer_Update(void);

#define TIMER0	0
#define TIMER1	1
#define TIMER2	2
#define TIMER3	3
#define TIMER4	4
#define TIMER5	5
#define TIMER6	6
#define TIMER7	7
#define TIMER8	8
#define TIMER9	9

void TIM0_CB(void *argv, uint16_t argc);
void TIM1_CB(void *argv, uint16_t argc);
void TIM2_CB(void *argv, uint16_t argc);
void TIM3_CB(void *argv, uint16_t argc);
void TIM4_CB(void *argv, uint16_t argc);
void TIM5_CB(void *argv, uint16_t argc);
void TIM6_CB(void *argv, uint16_t argc);
void TIM7_CB(void *argv, uint16_t argc);
void TIM8_CB(void *argv, uint16_t argc);
void TIM9_CB(void *argv, uint16_t argc);

#endif
